import java.util.Map;

public class Demo {
    public static void main(String[] args) {
        reverse(123);
    }
    public static int reverse(int x) throws NumberFormatException {
        String s=new StringBuilder().append(Math.abs(x)).reverse().toString();
        if(x<0)
            return -1*Integer.parseInt(s);
        else
            return Integer.parseInt(s);
    }
}
